//
//  personalLndexViewController.swift
//  万才信息App
//
//  Created by 陌上互联  on 16/7/17.
//  Copyright © 2016年 万才信息. All rights reserved.
//

import UIKit

class personalLndexViewController: UITableViewController {

    @IBOutlet weak var tvWorkYear: UILabel!
    @IBOutlet weak var tvMarriage: UILabel!
    @IBOutlet weak var tvSex: UILabel!
    @IBOutlet weak var tvUsername: UILabel!
    @IBOutlet weak var tvBirthday: UILabel!
    @IBOutlet weak var tvDegree: UILabel!
    @IBOutlet weak var tvPhoneNum: UILabel!
    @IBOutlet weak var tvEmail: UILabel!
    
    private let NON_DATA="未填写"
    
    private let waiting=waitingAlertUtil(msg: "加载中，请稍后..")
    private let CURR_USER_ID=userUtil.getCurrUserId()
    
    private func loadUserData(){
        waiting.show(self)
        basicInfo.getUserInfoByID(CURR_USER_ID, successCallback: { (data) in
            //            匹配信息
            self.waiting.stop()
            
            if(data == nil){
//                用户没有填写信息
                self.tvUsername.text=self.NON_DATA
                self.tvSex.text=self.NON_DATA
                self.tvMarriage.text=self.NON_DATA
                self.tvBirthday.text=self.NON_DATA
                self.tvDegree.text=self.NON_DATA
                self.tvWorkYear.text=self.NON_DATA
                self.tvPhoneNum.text=self.NON_DATA
                self.tvEmail.text=self.NON_DATA
            }else{
//                用户填写了信息
                self.tvUsername.text=data["UserName"].string

                self.tvBirthday.text=data["Birthday"].string

                self.tvPhoneNum.text=data["Mobile"].string
                self.tvEmail.text=data["Email"].string
            }
        }) { (error) in
            self.waiting.stop()
            warningAlertUtil(title: "错误", msg: "获取用户个人信息失败").show(self)
        }

    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        //Add your code here
        
    }
    
    override func viewDidAppear(animated: Bool) {
        super.viewDidAppear(animated)
        
        loadUserData()
    }
    
    
}
